#include <iostream>
#include "./json/json.hpp"
#include "./parser/parser.hpp" 

using namespace std;
using namespace imitation::json;

int main(int argc, char const *argv[])
{
  /*Json j1;
    Json j2(true);
    Json j3(1);
    Json j4(1.0);
    Json j5("hello");
    Json j6(string("world"));
    Json j7(vector<Json>{j1, j2, j3, j4, j5, j6});
    Json j8(map<string, Json>{{"j1", j1}, {"j2", j2}, {"j3", j3}, {"j4", j4}, {"j5", j5}, {"j6", j6}});
    */
    
    //数组API设计
    //可以通过[]访问、修改数组元素，通过.访问、修改对象元素，使用append()向数组中添加元素，使用insert()向对象中添加元素
    //所以要重载[]和.运算符，以及添加append()和insert()函数
    /*Json arr;
    arr[0] = true;
    arr[1] = 123;
    arr.append("hello");
    arr[3] = 5.67;
    // bool b = arr[0];
    // int i = arr[1];          
    // string s = arr[2];
    // double d = arr[3];
    // cout << b << endl;
    // cout << i << endl;
    // cout << s << endl;
    // cout << d << endl;
    cout<< arr.str() << endl;
    */
    /*
    //object API设计
    Json obj;
    obj["name"] = "zhangsan";
    obj["age"] = 18;
    // obj.insert("sex", "male");
    obj["sex"] = "male";
    cout << obj.str() << endl;
    cout << obj.has(0) << endl;
    cout << obj.has("name") << endl;
    obj.remove("age");
    cout << obj.str() << endl;
    */
    
    string a_null_json = "null";
    string a_bool_json = "true";
    string a_int_json = "123";
    string a_double_json = "3.1415926";
    string a_string_json = "\"hello world\"";
    string a_array_json = "[true, 123, \"hello world\", 3.1415926]";
    string a_object_json = "{\"name\":\"zhangsan\",\"age\":18,\"sex\":\"male\"}";
    string a_mix_json = "{\"name\":\"zhangsan\",\"age\":18,\"sex\":\"male\",\"hobby\":[\"swimming\",\"running\"]}";
    Json j;
    j.parse(a_null_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_bool_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_int_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_double_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_string_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_array_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_object_json);
    printf("%s\n", j.str().c_str());
    j.parse(a_mix_json);
    printf("%s\n", j.str().c_str());
    return 0;
}